<template>
  <div>
    <el-button size="small" type="primary" style="margin-right: 10px;" @click="edit(data)">
      编辑</el-button>

    <el-popconfirm title="确定删除本条数据吗?" @confirm="confirmEvent" @cancel="cancelEvent" confirm-button-text="确定"
      placement="top" cancel-button-text="取消">
      <template #reference>
        <el-button size="small">删除</el-button>
      </template>
    </el-popconfirm>

  </div>
</template>

<script setup lang="ts">

import { crud, onDelete } from '/@/crud/crud'
import { Delete, Edit, DocumentAdd, Download, Upload } from '@element-plus/icons-vue'
import { del } from '/@/api/system/menu';
import { ElMessage } from 'element-plus'
const emit = defineEmits(['toEditData', 'reasonData'])
const props = defineProps({
  data: { type: Object },
});

const edit = (data) => {
  emit('toEditData', data)
}
const confirmEvent = () => {
  console.log('confirm!', props.data.id)
  del({
    menuId: props.data.id
  }).then((res: any) => {
    ElMessage.success('删除成功');
    emit('reasonData')
  })

}
const cancelEvent = () => {
  console.log('cancel!')
}
</script>